import 'package:flutter/material.dart';

class SceneStateContext with ChangeNotifier {
  Offset _positon = Offset(0, 0);

  double _scale = 1.0;

  double mouseScaleSpeed = 0.8;

  double maxScale = 8.0;

  double minScale = 0.1;

  Color color = Colors.white;

  GlobalKey sceneGlobalKey = GlobalKey();

  bool interactive = true;

  bool initialized = false;

  Offset get position => _positon;

  double get scale => _scale;

  update() {
    notifyListeners();
  }

  setPosition(Offset position) {
    _positon = position;
  }

  setScale(double scale) {
    _scale = scale;
  }

  updatePosition(Offset offset) {
    _positon += offset;
  }

  updateScale(double scale) {
    _scale *= scale;
  }

  reset() {
    _positon = Offset(0, 0);
    _scale = 1.0;
    notifyListeners();
  }

  Offset fromSceneCoordinates(Offset pos) {
    return (pos - position) / scale;
  }

  Offset toSceneCoordinates(Offset pos) {
    return pos * scale + this.position;
  }
}
